package com.hcc.gateway.netty.context;

import java.util.Map;

/**
 * 网关filter报文
 *
 * @author hushengjun
 * @date 2021/12/26
 */
public interface GatewayExchange {

    ReqContext getReqContext();

    RespContext getRespContext();

    Map<String, Object> getAttributes();

    default void addAttribute(String name, Object value) {
        this.getAttributes().put(name, value);
    }

    default Object getAttributeByName(String name) {
        return this.getAttributes().get(name);
    }

    default <T> T getAttributeByName(String name, Class<T> clazz) {
        return clazz.cast(this.getAttributeByName(name));
    }

}
